home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Origami / bindings / fun / tab < prev    next >
Encoding:
Text File  |  1996-09-27  |  3.1 KB  |  108 lines

  1. {{{  comments
  2. ; This macro simulates tab-keys (using spaces to go to next position!)
  3. ; you can define 4 tab-width in the following way:
  4. ;   tab-width  /tab-count:   the first tab-count jumps use tab-width
  5. ;   tab-width-1/tab-count-1: the next tab-count-1 jumps use tab-width-1
  6. ;   tab-width-2/tab-count-2: the next tab-count-2 jumps use tab-width-2
  7. ;   tab-width-3:             this is the width for all following jumps
  8. ; negative values for counts have the effect, that the corresponding
  9. ; width-values are use for all following jumps.
  10. ;
  11. ; for example:
  12. ;
  13. ;* the startup-values are:
  14. ;    tab-width 1
  15. ;    tab-count -1
  16. ;  these values let tab have the same effect as space
  17. ;
  18. ;* given the values:
  19. ;    tab-width=2     tab-count=1
  20. ;    tab-width-1=3   tab-count-1=2
  21. ;    tab-width-2=4   tab-count-2=2
  22. ;    tab-width-3=5
  23. ;
  24. ;  the resulting tab-positions are:
  25. ;
  26. ;  a b  c  d   e   f    g    h    i    j    k    l    m
  27. ;  ^ ^  ^  ^   ^   ^    ^    ^    ^    ^    ^    ^    ^
  28. ;  | |  |  |   |   |    all following jumps use tab-width-3
  29. ;  | |  |  |   |   |
  30. ;  | |  |  |   tab-width-2-jumps
  31. ;  | |  |  |
  32. ;  | |  tab-width-1-jumps
  33. ;  | |
  34. ;  | tab-width-jump
  35. ;  |
  36. ;  first character in line
  37. }}}
  38. @if-using not(TAB)
  39.   @use (TAB)
  40.   {{{  vars
  41.   ( defvar
  42.      ( tab-width          ; first tab-step
  43.        tab-count          ; number of usages for ^, <0 -> always
  44.        tab-width-1        ; second tab-step
  45.        tab-count-1        ; number of usages of step 2
  46.        tab-width-2        ; third tab-step
  47.        tab-count-2        ; number of usages of step 3
  48.        tab-width-3        ; last tab-step
  49.        tab-missing-spaces ; help-counter
  50.      )
  51.   )
  52.   }}}
  53.   {{{  go_to_next_tab
  54.   (deffun go_to_next_tab (
  55.     if in-prompt ( return-from-macro ) fi
  56.     {{{  maybe initialise the counter for tab-width
  57.     if <=(tab-width 0) ( set tab-width 0 ) fi
  58.     }}}
  59.     if =(tab-width 0)
  60.      ( insert-ascii 9 return-from-macro )
  61.     fi
  62.     {{{  tab-missing-spaces = #missing `` ''
  63.     set tab-missing-spaces -(1 +(store-pos set-space-enter))
  64.     local (tab-count tab-count-1 tab-count-2) (
  65.       do (
  66.         case
  67.           ( tab-count
  68.              ( set tab-missing-spaces +(tab-missing-spaces tab-width  )
  69.                set tab-count  +(tab-count   -1)
  70.              )
  71.           )
  72.           ( tab-count-1
  73.              ( set tab-missing-spaces +(tab-missing-spaces tab-width-1)
  74.                set tab-count-1 +(tab-count-1 -1)
  75.              )
  76.           )
  77.           ( tab-count-2
  78.              ( set tab-missing-spaces +(tab-missing-spaces tab-width-2)
  79.                set tab-count-2 +(tab-count-2 -1)
  80.              )
  81.           )
  82.         default
  83.           (set tab-missing-spaces +(tab-missing-spaces tab-width-3))
  84.         esac
  85.       ) while <=(tab-missing-spaces 0)
  86.     )
  87.     }}}
  88.     {{{  insert the spaces
  89.     do
  90.      ( "  ;
  91.        set tab-missing-spaces +(tab-missing-spaces -1)
  92.      )
  93.     while <>(tab-missing-spaces 0)
  94.     }}}
  95.   ))
  96.   }}}
  97.   {{{  define-tab
  98.   (deffun define-tab (
  99.     if in-prompt ( return-from-macro ) fi
  100.     prompt-counter tab-width (M_TABSIZE "  "? )
  101.     set tab-count -1
  102.   ))
  103.   }}}
  104.   {{{  undeclare
  105.   ( undeclare ( tab-missing-spaces ) )
  106.   }}}
  107. @fi
  108.